<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>平台选择</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!--标准mui.css-->
		<link rel="stylesheet" href="css/mui.min.css">
		<style>
			
			.mui-content-padded{
			  	margin: 10px;
			}
			.ok-button {
				width: 100%;
				height: 48px;
				margin-top: 20px;
				background-color: #6AA2E0;
				color: white;
				letter-spacing: 5px;
				font-size: 16px;
				cursor: pointer;
				border: none;
			}
			[v-cloak] {
				display: none;
			}
		</style>
	</head>

	<body>
		<div id="App" v-cloak>
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<h1 class="mui-title">后台地址配置</h1>
			</header>
			<div class="mui-content">
				<h5 class="mui-content-padded">平台登录地址</h5>
				<div class="mui-card">
					<div class="mui-input-group">
						<div class="mui-input-row">
							<input v-model="url" name="text" type="text" placeholder="输入平台登录地址url">
						</div>
					</div>
				</div>
				<div class="mui-content-padded">
				    <button @click="setUrl" type="button" class="mui-btn  mui-btn-block ok-button">确定</button>
				</div>
			</div>
		</div>
		
	</body>
	<script src="js/mui.min.js"></script>
	<script src="js/common.js"></script>
	<script src="js/vue.min.js"></script>
	<script type="text/javascript">
		var mv = new Vue({
			el:"#App",
			data:{
				url:''
			},
			methods: {
				setUrl:function(){
					if(this.url == ""){
						mui.toast("登录地址不能为空!")
					}else {
						var address = this.url;
						var svgAddress = '';
						
						var lastIndex = address.lastIndexOf('/');
						//去除最后的'/'
						if(lastIndex == (address.length-1) ){
							address = address.substring(0,lastIndex);
							var index = address.lastIndexOf('/');
							if(index !=-1){
								svgAddress = address.substring(0,index);
							}
						}else {
							var index = address.lastIndexOf('/');
							if(index !=-1){
								svgAddress = address.substring(0,index);
							}
						}
					
						if(address.indexOf("http")!=-1 || address.indexOf("https")!=-1 ){
							address =address + '/';
							svgAddress = svgAddress +'/file/pd/';
						}else {
							address ="http://"+address + '/';
							svgAddress ="http://"+svgAddress +'/file/pd/';
						}
						
						setUrl(address);
						setSvgUrl(svgAddress);
						mui.back();
						
					}
				}
			},
			mounted:function(){
				this.url = getUrl();
				mui.init();
			}
		})
		
	</script>
</html>